import request, { ApiResponse } from '@/utils/service/request'
import { ClientItem, OptionClientReq } from './model/openapiModel'

export enum OpenAApi {
  /** 显示外部应用 */
  GET_CLIENT_LIST = '/user-center/oauth-client-details/select',
  /** 新增和更新接口 */
  OPTION_CLIENT = '/user-center/oauth-client-details/insertAndUpdate',
  /** 删除Client */
  DELETE_CLIENT = '/user-center/oauth-client-details/delete',
}

export function fetchClientList() {
  return request.get<ApiResponse<ClientItem[]>>(OpenAApi.GET_CLIENT_LIST)
}

export function optionClient(body: OptionClientReq) {
  return request.post<ApiResponse<null>>(OpenAApi.OPTION_CLIENT, body)
}

export function deleteClient(clientId: string) {
  return request.post<ApiResponse<null>>(OpenAApi.DELETE_CLIENT, { clientId })
}
